import org.openqa.selenium.WebElement;
import org.openqa.selenium.RenderedWebElement;

// Go to the Google Suggest home page
browser.get("http://www.google.com/webhp?complete=1&hl=en");

// Enter the query string "Cheese"
def query = browser.findElement(By.name("q"));
query.sendKeys("Cheese");
query.sendKeys("Cheese ");

// Sleep until the div we want is visible or 5 seconds is over
long end = System.currentTimeMillis() + 15000;
while (System.currentTimeMillis() < end) {
	// Browsers which render content (such as Firefox and IE) return "RenderedWebElements"
	RenderedWebElement resultsDiv = (RenderedWebElement) browser.findElement(By.className("gac_m"));
	
	// If results have been returned, the results are displayed in a drop down.
	if (resultsDiv.isDisplayed()) {
		break;
	}
}

// And now list the suggestions
List<WebElement> allSuggestions = browser.findElements(By.xpath("//td[@class='gac_c']"));

def count = 0;
for (WebElement suggestion : allSuggestions) {
	results.put(count.toString(), suggestion.getText());
	count++;
}